<?php
interface Brand
{
    public function getName();
}
abstract class Computer
{
    /** @var Brand $brand */
    protected $brand=null;
    public function __construct($brand)
    {
        $this->brand=$brand;
    }
    public function sale()
    {
        return $this->brand->sale();
    }
}

class Lenovo implements Brand
{
    public function getName()
    {
        return "联想";
    }
}
class Dell implements Brand
{
    public function getName()
    {
        return "戴尔";
    }
}
class Shenzhou implements Brand
{
    public function getName()
    {
        return "神舟";
    }
}

class Desktop extends Computer
{
    public function sale()
    {
        echo "出售" . $this->brand->getName() . "台式电脑\r\n";
    }
}
class Laptop extends Computer
{
    public function sale()
    {
        echo "出售" . $this->brand->getName() . "笔记本电脑\r\n";
    }
}

header('Content-Type: text/plain');

$computer = new Desktop(new Dell);
$computer->sale();
